{% extends 'layout.html' %}

{% block main %}
<div class="center banner">
    <img src="/public/imgs/banner.jpg" alt="">
    <h2></h2>
</div>
<div class="center">
    <div class="article_list">
        {% for content in contents %}
        <a class="article_item" href="/view?contentid={{content.id}}">
            <h3> {{content.title}} <span>作者：<i>{{content.user.username}}</i> - 阅读：<i>{{content.views}}</i> - 评论：<i>{{content.comments.length}}</i></span></h3>
            <div class="article_main">
                <p class="article_content ellipsis_4">{{content.description}}</p>
            </div>
            <div class="article_tag">
                <span>{{content.category.name}}</span>
                <i>{{content.addTime|date('Y年m月d日 H:i:s', -8*60)}}</i>
            </div>
        </a>
        {% endfor %}

        {% if totalPage>1 %}
        <div class="pagination">
            {% if page<=1 %}
            <span class="pagination_left">没有了</span>
            {% else %}
            <a class="pagination_left" href="/?categoryType={{categoryType}}&page={{page-1}}">上一页</a>
            {% endif %}
            <span><i>{{page}}/{{totalPage}}</i></span>
            {% if page>=totalPage %}
            <span class="pagination_right">没有了</span>
            {% else %}
            <a class="pagination_right" href="/?categoryType={{categoryType}}&page={{page+1}}">下一页</a>
            {% endif %}
        </div>
        {% elseif count==0 %}
        <p class="noPageList">没有相关内容</p>
        {% endif %}
    </div>
    <aside class="user_list">
        {% if userInfo.uid %}
        <div class="user_logined">
            <p class="user_welcome">欢迎，<i>{{userInfo.username}}</i>
                {% if userInfo.isAdmin %}
                <a href="/admin">进入后台</a>
                {%endif%}
            </p>
            <span id="loginOut" class="user_loginOut">退出</span>
        </div>
        {% else %}
        <div class="user_form">
            <div class="user_tab j_userTab">
                <span class="user_cur">登录</span>
                <span>注册</span>
            </div>
            <div id="login" class="user_login">
                <div class="user_input">
                    <i class="iconfont">&#xe60d;</i>
                    <input type="text" placeholder="请输入用户名">
                </div>
                <div class="user_input margin_bottom0">
                    <i class="iconfont">&#xe6c6;</i>
                    <input type="password" placeholder="请输入密码">
                </div>
                <p class="user_err"><span>用户名不能为空</span></p>
                <p class="user_login_btn">登 录</p>
            </div>
            <div id="register" class="user_register">
                <div class="user_input">
                    <i class="iconfont">&#xe60d;</i>
                    <input type="text" placeholder="请输入用户名">
                </div>
                <div class="user_input">
                    <i class="iconfont">&#xe6c6;</i>
                    <input type="password" placeholder="请输入密码">
                </div>
                <div class="user_input margin_bottom0">
                    <i class="iconfont">&#xe6c6;</i>
                    <input type="password" placeholder="请再次输入密码">
                </div>
                <p class="user_err"><span>用户名不能为空</span></p>
                <p class="user_register_btn">注 册</p>
            </div>
        </div>
        {%endif%}
        <div class="friendly_link">
            <div class="user_tab">
                <span class="discuss_title">友情链接</span>
            </div>
            <div class="link_item">
                <a href="http:www.zhihu.com">知乎</a>
            </div>
        </div>
        <p class="user_no">您是本网站的第<i>12</i>位访客祝您生活工作愉快</p>
        <p class="copy_right">京ICP备17059284号-1</p>
    </aside>
</div>
<script src="/public/js/index.js"></script>
{% endblock %}